/*
 * Copyright (C) 2015-2019 Alibaba Group Holding Limited
 */

#ifndef CO_MASTER__H_
#define CO_MASTER__H_
#include <stdint.h>
#include <stdbool.h>

#include "canopen/canopen.h"
#include "canopen/io_board_api.h"
#ifdef __cplusplus
extern "C" {
#endif


typedef void (*can_io_state_change_cb)(const uint8_t can_port, const uint8_t node, const io_board_state_t state);

typedef void (*can_io_input_change_cb)(const uint8_t can_port, const uint8_t node, const uint8_t input_level_size, const uint8_t input_level[8]);

/*
 * Function prototype for initialize CANopen master
 *
 * @param  can_port  CAN Logical Port, mapping between logical and physical reference board.c
 * @param  node_list Node List of components which this master maintain.
 * @param  node_cnt  Sizeof of Node List
 *
 * @return  0: success; other: fail.
 */
int32_t co_master_init(const uint8_t can_port, const uint8_t *node_list, const uint8_t node_cnt, can_io_state_change_cb state_change_cb, can_io_input_change_cb input_change_cb);


int32_t gpio_set_output(const uint8_t can_port, const uint8_t node, const uint8_t gpio_number, const bool set);

#ifdef __cplusplus
}
#endif

#endif /* CO_MASTER__H_ */
